﻿using System.Diagnostics.Contracts;
namespace ATM.Components
{

    /// <summary>
    /// Represents printer component.
    /// </summary>
    class Printer
    {
        public int confirmationsLeftToPrint { get; private set; }

        public Printer()
        {
            confirmationsLeftToPrint = 100;
        }

        /// <summary>
        /// Checks if there is enough paper in printer and printer is operating.
        /// </summary>
        /// <returns>true if printer is ready to print</returns>
        internal bool CheckPaper()
        {
            return confirmationsLeftToPrint > 0;
        }

        /// <summary>
        /// Prints confirmation that credit card was withheld.
        /// </summary>
        /// <returns>true</returns>
        internal bool PrintCardWithheldConfirmation()
        {
            Contract.Requires(confirmationsLeftToPrint > 0);

            --confirmationsLeftToPrint;
            System.Console.WriteLine(">> Printer: This is a confirmation that your card was withheld.");
            return true;
        }

        /// <summary>
        /// Prints transaction confirmation.
        /// </summary>
        /// <param name="amount">Amount of transaction</param>
        /// <returns>true</returns>
        internal bool PrintTransactionConfirmation(int amount)
        {
            Contract.Requires(confirmationsLeftToPrint > 0);
            Contract.Requires(amount > 0);

            --confirmationsLeftToPrint;
            System.Console.WriteLine(">> Printer: This is a confirmation that DKK {0} was withdrawn from your account.", amount);
            return true;
        }

    }
}
